feat: Add OpaClient to wrap auth checks#1541
Open
tpoliaw wants to merge 5 commits into
Open
Conversation
e8ddc77 to
db3325b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## depends-user #1541 +/- ##
================================================
+ Coverage 95.63% 95.77% +0.14%
================================================
Files 43 44 +1
Lines 3228 3264 +36
================================================
+ Hits 3087 3126 +39
+ Misses 141 138 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fajinyuan
reviewed
Jun 2, 2026
ZohebShaikh
reviewed
Jun 4, 2026
| } | ||
| }, | ||
| ) | ||
| return (await resp.json())["result"] |
Contributor
There was a problem hiding this comment.
nit: Will be good to TypeAdapter the result to bool because of python
Something like this
from pydantic import TypeAdapter
return TypeAdapter(bool).validate_python((await resp.json())["result"])
I think we should as put this in
try:
TypeAdapter(bool).validate_python((await resp.json())["result"])
except KeyError : # on result unlikely
...
except Timeout to OPA as e:
raise e as Timeouterror
or just Exception
Contributor
Author
There was a problem hiding this comment.
What does the TypeAdapter protect against? OPA returning "False" instead of False?
For the exception handling, does wrapping the exception here add much beyond letting the original exception be raised?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proof of concept opa client with dependency injection and example check